package main

import (
	"fmt"
	"io"
	"os"
)

func readMaze(reader io.Reader) [][]int {
	var r, c int
	fmt.Fscanf(reader, "%d %d", &r, &c) //fmt.Fscanf 从io.reader中按照格式化字符串读取数据，遇到空格或换行符会结束读取
	maze := make([][]int, r)
	fmt.Println(maze)
	for i := range maze {
		maze[i] = make([]int, c)
		for j := range maze[i] {
			fmt.Fscanf(reader, "%d", &maze[i][j])
		}
	}
	return maze
}
func main() {
	file, err := os.Open("maze/maze.in")
	if err != nil {
		panic(err)
	}
	maze := readMaze(file)
	fmt.Println(maze)
}
